import React, { Component } from 'react';
import { Switch, Route, Redirect } from 'react-router-dom'
class Routerview extends Component {
  render() {
    const { routes } = this.props
    return (
      <Switch>
        {
          routes.length > 0 && routes.map((v, i) => {
            return (
              v.path 
                ? <Route path={ v.path } key={i} render={ (props) => <v.component { ...props } routes={ v.children }></v.component> }></Route>
                : v.from 
                    ? <Redirect from={v.from} to={v.to} key={i} exact></Redirect>
                    : <Route component={ v.component } key={i}></Route>
            )
          })
        }
      </Switch>
    );
  }
}

export default Routerview;
